package com.xbongbong.admin.model.impl;

import com.xbongbong.admin.domain.dao.PaasLabelDao;
import com.xbongbong.admin.domain.entity.PaasLabelEntity;
import com.xbongbong.admin.model.PaasLabelModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 应用标签
 * @author xingxing.xiao
 * @date 2020/01/09 20:08
 */
@Service("paasLabelModel")
public class PaasLabelModelImpl implements PaasLabelModel {

    @Resource
    private PaasLabelDao paasLabelDao;

    @Override
    public Integer insert(PaasLabelEntity entity) throws XbbException {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return paasLabelDao.insert(entity);
    }

    @Override
    public Integer update(PaasLabelEntity entity) throws XbbException {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return paasLabelDao.update(entity);
    }

    @Override
    public List<PaasLabelEntity> findEntitys(Map<String, Object> param) {
        return paasLabelDao.findEntitys(param);
    }

    /**
     * 查询某类型下最大的排序
     * @param type
     * @return
     */
    @Override
    public Integer getMaxSortByType(Integer type) {
        return paasLabelDao.getMaxSortByType(type);
    }

    @Override
    public List<PaasLabelEntity> getByType(int type) {
        return paasLabelDao.getByType(type);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return paasLabelDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }
}
